package com.jmlee.controller;

import com.jmlee.enums.OrderStatusEnum;
import com.jmlee.exception.Asserts;
import com.jmlee.pojo.CommonResult;
import com.jmlee.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 支付接口服务
 * @Author jmLee
 * @Date 2021/3/14 11:42
 * @Version 1.0
 */
@RestController
public class PayController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/pay")
    public CommonResult pay(Long orderId, Integer amount) {

        System.out.println(orderId);
        System.out.println(amount);

        if (orderId == null || amount == null) {
            Asserts.fail("请求参数不能为空");
        }

        orderService.updateOrderStatus(orderId, OrderStatusEnum.WAIT_DELIVER.code);

        return CommonResult.success("支付成功");

    }
}
